package com.ruihu.admin.module.business.task.domain.vo;

import com.ruihu.admin.module.business.task.domain.dto.TaskDTO;
import com.ruihu.admin.module.business.task.domain.entity.TaskEntity;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;

/**
 *  [ 任务主表 ]
 *
 * @author Tony
 * @version 1.0
 * @company 瑞虎（南京）信息技术有限公司
 * @copyright (c) 瑞虎（南京）信息技术有限公司Inc. All rights reserved.
 * @date  2022-08-26 20:42:35
 * @since JDK1.8
 */
@Data
public class TaskVO {
    @ApiModelProperty("主键")
    private Long id;

    @ApiModelProperty("任务编号")
    private String taskCode;

    @ApiModelProperty("任务名称")
    private String taskName;

    @ApiModelProperty("任务描述")
    private String taskDesc;

    @ApiModelProperty("计划总数")
    private Integer planNum;

    @ApiModelProperty("计划开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date planStartTime;

    @ApiModelProperty("计划结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date planEndTime;

    @ApiModelProperty("任务优先级ID")
    private Long priorityId;

    @ApiModelProperty("任务进度")
    private BigDecimal progress;

    @ApiModelProperty("任务优先级描述")
    private String priorityDesc;

    @ApiModelProperty("完成时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date completionTime;

    @ApiModelProperty("状态")
    private String status;

    @ApiModelProperty("任务状态描述")
    private String statusDesc;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty("创建人")
    private String createByName;

    public static TaskVO convertToTaskVO(TaskDTO taskDTO) {
        if (taskDTO == null) {
            return null;
        }
        TaskVO taskVO = new TaskVO();
        taskVO.setId(taskDTO.getId());
        taskVO.setTaskCode(taskDTO.getTaskCode());
        taskVO.setTaskName(taskDTO.getTaskName());
        taskVO.setTaskDesc(taskDTO.getTaskDesc());
        taskVO.setPlanNum(taskDTO.getPlanNum());
        taskVO.setPlanStartTime(taskDTO.getPlanStartTime());
        taskVO.setPlanEndTime(taskDTO.getPlanEndTime());
        taskVO.setPriorityId(taskDTO.getPriorityId());
        taskVO.setCompletionTime(taskDTO.getCompletionTime());
        taskVO.setStatus(taskDTO.getStatus());
        taskVO.setStatusDesc(taskDTO.getStatusDesc());
        taskVO.setCreateTime(taskDTO.getCreateTime());
        taskVO.setUpdateTime(taskDTO.getUpdateTime());
        taskVO.setCreateByName(taskDTO.getCreateByName());
        return taskVO;
    }

    public static TaskVO convertToTaskVO(TaskEntity entity) {
        if (entity == null) {
            return null;
        }
        TaskVO taskVO = new TaskVO();
        taskVO.setId(entity.getId());
        taskVO.setTaskCode(entity.getTaskCode());
        taskVO.setTaskName(entity.getTaskName());
        taskVO.setTaskDesc(entity.getTaskDesc());
        taskVO.setPlanNum(entity.getPlanNum());
        taskVO.setPlanStartTime(entity.getPlanStartTime());
        taskVO.setPlanEndTime(entity.getPlanEndTime());
        taskVO.setPriorityId(entity.getPriorityId());
        taskVO.setCompletionTime(entity.getCompletionTime());
        taskVO.setStatus(entity.getStatus());
        taskVO.setCreateTime(entity.getCreateTime());
        taskVO.setUpdateTime(entity.getUpdateTime());
        return taskVO;
    }
}
